package com.bd.scm.dao.mapper.overTime;

import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bd.scm.domain.dto.leave.BdLeaveOrderSerachDto;
import com.bd.scm.domain.dto.overTime.*;
import com.bd.scm.domain.models.overTime.OverTimeOrder;
import com.bd.scm.domain.models.overTime.OverTimeOrderAll;
import com.bd.scm.domain.models.overTime.OverTimeOrderExport;
import com.bd.scm.domain.models.overTime.OverTimeView;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: _Cps
 * Date: 2019.12.14 9:33
 */
public interface OverTimeOrderMapper extends BaseMapper<OverTimeOrder> {

    IPage<OverTimeOrderAll> getOverTimeOrderList(Page<OverTimeOrderAll> page, OverTimeOrderDto overTimeOrderDto);

    List<OverTimeOrder> getDetailOfOrder(OverTimeOrderDto overTimeOrderDto);

    Integer checkExists(OverTimeOrderDto overTimeOrderDto);

    List<OverTimeOrderFailDto> addOverTimeOrder(OverTimeOrderDto overTimeOrderDto);

    Integer deleteOverTimeOrder(OverTimeOrderDto overTimeOrderDto);

    Integer checkOverTimeType(OverTimeOrderDto overTimeOrderDto);
    /**
     * 根据单子ID修改单子状态和审批人.
     *
     * @param orderId
     * @param status
     * @param approver
     */
    void updateOverTimeOrder(@Param("orderId") String orderId, @Param("status") Integer status, @Param("approver")
            String approver,@Param("remark")
                                     String remark);

    /**
     * 查询通过的单子
     * @param overTimeOrderDto orderNo 编号模糊查询
     * @return orderNo,sumUser
     */
    List<OverTimeOrder> findOrderNoList(OverTimeOrderDto overTimeOrderDto);

    /**
     * 获取加班个人的列表.
     *
     * @param bdLeaveOrderSerachDto 条件
     * @return
     */
    IPage<OverTimeOfPersonalDto> getOtOfPersonalList(Page<OverTimeOfPersonalDto> page, BdLeaveOrderSerachDto
        bdLeaveOrderSerachDto);

    /**
     * 根据单子id获取实例ID.
     * @param orderId
     * @return
     */
    String getProcessInstanceId(@Param("orderId") Integer orderId);

    List<OverTimeOrderExport> getOverTimeOrderExportList(@Param("overTimeOrderDto") OverTimeOrderDto overTimeOrderDto);

    Integer deleteOverTimeOrderDetail(OverTimeDetailDto overTimeDetailDto);

    /**
     * 审批结束，调用存储过程，重新计算考勤.
     * @param orderId
     */
    void doOverTimeResult(@Param("orderId")String orderId);

    /**
     * 获取加班个人的列表.
     *
     * @param bdLeaveOrderSerachDto 条件
     * @return
     */
    List<OverTimeOfPersonalDto> getPersonalExportList(@Param("param2") BdLeaveOrderSerachDto
            bdLeaveOrderSerachDto);

    /**
     *
     */
    Integer getOrderNoByFz(String orderNo);

    /**
     * 保存导入的数据.
     *
     * @param receiveList
     * @param serialNumber
     * @param operator
     */
    void saveImportFile(@Param("list") List<ImportOverTimeDataDto> receiveList, @Param("serialNumber") String serialNumber,
                        @Param("operator") String operator);

    /**
     *
     * @param serialNumber
     * @param operator
     * @return
     */
    List<JSONObject> execImportOverTime(@Param("serialNumber") String serialNumber,
                                        @Param("operator") String operator);
    /**
     * 获取员工指定日期的加班数据
     *
     * @param userId
     * @param date
     * @return
     */
    List<OverTimeView> getByAndDate(@Param("userId") Long userId, @Param("date") String date);

    /**
     * 排班加班单预处理
     *
     */
    void overTimePreHandle();
}
